<?php
class Site_Model_Sitemap extends Promotor_Model_Abstract {

	protected $_dbTableClass = 'Site_Model_DbTable_Site';

	/**
	 * @todo Dodać keszowanie!
	 * @return Zend_Navigation
	 */
	public function getNavigation() {
		$table = $this->getDbTable();
		
		$select = $table->select()
						->where('publicated = ?', '1')
						->order('idx ASC');

		try {
			$rowset = $table->fetchAll($select);
			$this->_setStatus(self::SUCCESS);
		} catch(Zend_Db_Exception $e) {
			$this->_setStatus(self::FAILURE);
			$this->_addException($e);
		}

		$recursive = new RecursiveIteratorIterator($rowset, RecursiveIteratorIterator::SELF_FIRST);
		$navigation = new KontorX_Navigation_Recursive($rowset);
		$navigation->accept(new Promotor_Navigation_Recursive_Visitor_Site());
		return $navigation->create();
	}
}